def do_something():
    try:
        print('do somthing')
        raise EOFError
        return '1'
    except EOFError:
        print('EOFError')
        return '2'
    except KeyError:
        print('KeyError')
    else:
        print('other Error')
        return '3'
    finally:
        print('finally')
        return '4'


class A:
    def __init__(self):
        print('ininalize')

    def __enter__(self):
        print('ready enter')
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        print('ready quit')

    def do_somthing(self):
        print('really do something')


with A() as sample:
    sample.do_somthing()

if __name__ == '__main__':
    pass
